<template>
	<view class="app_yaoqing" :class='equipment'>
		<image style="width: 100%;" :src="res.result.img" mode="widthFix" v-if="res !== ''"></image>
	</view>
</template>

<script>
	import {
		commission_qrcode,
		member
	} from '@/api/member.js';

	export default {
		data() {
			return {
				openid: '',
				e: '',
				res: '',
				equipment: ''
			};
		},
		onLoad(e) {
			this.e = e;
		},
		onShow() {
			if (process.env.UNI_PLATFORM === 'h5') {
				// 在H5环境中打开
				console.log('在H5环境中打开');
				this.equipment = 'H5'
			} else if (process.env.UNI_PLATFORM === 'app-plus') {
				// 在App环境中打开
				console.log('在App环境中打开');
				this.equipment = 'App'
			}
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data;
					this.memberFun();
				},
				fail: () => {
					uni.reLaunch({
						url: '/pages/login/login'
					});
				}
			});
		},
		methods: {
			async memberFun() {
				let data = await member(this.openid);
				console.log(data);
				this.commission_qrcodeFun(data.id);

			},
			async commission_qrcodeFun(mid) {
				let up = {
					openid: this.openid,
					mid
				}
				let data = await commission_qrcode(up);
				this.res = data;
			},
		}
	}
</script>

<style lang="scss" scoped>
	.App {
		height: 100vh;
	}

	.H5 {
		height: calc(100vh - 88rpx);
	}

	.app_yaoqing {
		width: 100%;
		background-color: #cc270a;
		position: relative;

		image {
			width: 100%;
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			// margin: auto;
		}

	}
</style>